//
//  HomeListDetailModel.swift
//  MT
//
//  Created by M on 2019/12/13.
//  Copyright © 2019 张强. All rights reserved.
//

import UIKit
import ObjectMapper
import MTCategory

class HomeListDetailReponseModel: Mappable {
    var page: PageModel?
    
    var result: [HomeListDetailModel]?
    
    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        result          <- map["result"]
        page          <- map["page"]
    }
}

class HomeListDetailModel: Mappable {
    /// 最后一条点赞的动态id
    var lastTrendId: Int?
    /// 自己是否已经点赞过
    var selfLike: Int = 0
    /// 用户Id
    var id: Int?
    /// 年龄
    var age: Int?
    
    /// 地区
    var area: String?
    
    /// 礼物金额
    var giftPrice: Int = 0
    
    /// 头像地址
    var headerUrl: String?
    
    /// 极光登录名称
    var userName: String?
    
    /// 用户昵称
    var nickname: String?
    
    /// 媒体信息
    var imgs: [UserMediaListModel]?
    
    var isFriend: Bool = false
    
    var objType: Int?
    /// 用户个性签名
    var signature: String?
    /// 最后一次在线时间
    var lastHeartTime: String?
    /// 最后一次在线时间文本
    var onlineStatusRemark: String?
    /// 是否在线
    var onlineStatus: Int?
    /// 性别
    var sex: Int?
    /// 被点赞数量
    var likeCount: Int = 0
    /// 是否包含视频
    var isContainVideo: Bool {
        return (imgs?.count ?? 0) > 1
    }
    
    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        lastTrendId              <- map["lastTrendId"]
        id              <- map["id"]
        likeCount              <- map["likeCount"]
        area            <- map["area"]
        giftPrice       <- map["giftPrice"]
        headerUrl       <- map["headerUrl"]
        isFriend        <- map["isFriend"]
        userName        <- map["userName"]
        nickname        <- map["nickname"]
        age             <- map["age"]
        imgs            <- map["imgs"]
        objType       <- map["objType"]
        signature        <- map["signature"]
        lastHeartTime        <- map["lastHeartTime"]
        onlineStatusRemark        <- map["onlineStatusRemark"]
        onlineStatus             <- map["onlineStatus"]
        sex            <- map["sex"]
        selfLike            <- map["selfLike"]
    }

}

class UserMediaListResponseModel: Mappable {
    
    var code: Int?
    
    var result: UserMediaListModel?
    
    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        code            <- map["code"]
        result          <- map["result"]
    }
}

class UserMediaListModel: Mappable {
    
    /// 主键
    var id: Int?
    
    /// 封面图
    var coverImg: String?
    
    /// 链接路径
    var href: String? = "https://"
    
    /// 类型 0 为图片 1 为视频
    var objType: Int?
    
    /// 1 为竖屏 2 为横屏 3 为宽屏
    var ratio: Int?
    
    /// 本地资源 - 未上传 - 修改个人资料时使用
    var localAsset: MTAsset?
    
    /// 上传状态
    var uploadStatus: UploadStatus = .none
    
    /// 上传进度
    var uploadProgress: Double = 0.0

    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        id              <- map["id"]
        coverImg        <- map["coverImg"]
        href            <- map["href"]
        objType         <- map["objType"]
        ratio           <- map["ratio"]
        localAsset      <- map["localAsset"]
    }
    
}
